// FrontEnd Plus GUI for JAD
// DeCompiled : Base64.class

package com.bizaid.ctrs.common;

import java.io.IOException;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public final class Base64
{

    private static final int BASELENGTH = 255;
    private static final int LOOKUPLENGTH = 64;
    private static final int TWENTYFOURBITGROUP = 24;
    private static final int EIGHTBIT = 8;
    private static final int SIXTEENBIT = 16;
    private static final int SIXBIT = 6;
    private static final int FOURBYTE = 4;
    private static final int SIGN = -128;
    private static final byte PAD = 61;
    private static byte base64Alphabet[];
    private static byte lookUpBase64Alphabet[];

    public Base64()
    {
    }

    public static boolean isBase64(String s)
    {
        return isArrayByteBase64(s.getBytes());
    }

    public static boolean isBase64(byte byte0)
    {
        return byte0 == 61 || base64Alphabet[byte0] != -1;
    }

    public static boolean isArrayByteBase64(byte abyte0[])
    {
        int i = abyte0.length;
        if(i == 0)
            return true;
        for(int j = 0; j < i; j++)
            if(!isBase64(abyte0[j]))
                return false;

        return true;
    }

    public static byte[] encode(byte abyte0[])
    {
        if(abyte0 == null)
            return null;
        int i = abyte0.length * 8;
        int j = i % 24;
        int k = i / 24;
        byte abyte1[] = null;
        if(j != 0)
            abyte1 = new byte[(k + 1) * 4];
        else
            abyte1 = new byte[k * 4];
        boolean flag = false;
        boolean flag1 = false;
        boolean flag2 = false;
        boolean flag3 = false;
        boolean flag4 = false;
        int l = 0;
        int i1 = 0;
        int j1 = 0;
        for(j1 = 0; j1 < k; j1++)
        {
            i1 = j1 * 3;
            byte byte5 = abyte0[i1];
            byte byte8 = abyte0[i1 + 1];
            byte byte10 = abyte0[i1 + 2];
            byte byte3 = (byte)(byte8 & 0xf);
            byte byte0 = (byte)(byte5 & 3);
            l = j1 * 4;
            byte byte11 = (byte5 & 0xffffff80) != 0 ? (byte)(byte5 >> 2 ^ 0xc0) : (byte)(byte5 >> 2);
            byte byte14 = (byte8 & 0xffffff80) != 0 ? (byte)(byte8 >> 4 ^ 0xf0) : (byte)(byte8 >> 4);
            byte byte16 = (byte10 & 0xffffff80) != 0 ? (byte)(byte10 >> 6 ^ 0xfc) : (byte)(byte10 >> 6);
            abyte1[l] = lookUpBase64Alphabet[byte11];
            abyte1[l + 1] = lookUpBase64Alphabet[byte14 | byte0 << 4];
            abyte1[l + 2] = lookUpBase64Alphabet[byte3 << 2 | byte16];
            abyte1[l + 3] = lookUpBase64Alphabet[byte10 & 0x3f];
        }

        i1 = j1 * 3;
        l = j1 * 4;
        if(j == 8)
        {
            byte byte6 = abyte0[i1];
            byte byte1 = (byte)(byte6 & 3);
            byte byte12 = (byte6 & 0xffffff80) != 0 ? (byte)(byte6 >> 2 ^ 0xc0) : (byte)(byte6 >> 2);
            abyte1[l] = lookUpBase64Alphabet[byte12];
            abyte1[l + 1] = lookUpBase64Alphabet[byte1 << 4];
            abyte1[l + 2] = 61;
            abyte1[l + 3] = 61;
        } else
        if(j == 16)
        {
            byte byte7 = abyte0[i1];
            byte byte9 = abyte0[i1 + 1];
            byte byte4 = (byte)(byte9 & 0xf);
            byte byte2 = (byte)(byte7 & 3);
            byte byte13 = (byte7 & 0xffffff80) != 0 ? (byte)(byte7 >> 2 ^ 0xc0) : (byte)(byte7 >> 2);
            byte byte15 = (byte9 & 0xffffff80) != 0 ? (byte)(byte9 >> 4 ^ 0xf0) : (byte)(byte9 >> 4);
            abyte1[l] = lookUpBase64Alphabet[byte13];
            abyte1[l + 1] = lookUpBase64Alphabet[byte15 | byte2 << 4];
            abyte1[l + 2] = lookUpBase64Alphabet[byte4 << 2];
            abyte1[l + 3] = 61;
        }
        return abyte1;
    }

    public static byte[] decode(byte abyte0[])
    {
        if(abyte0.length == 0)
            return new byte[0];
        int i = abyte0.length / 4;
        byte abyte1[] = null;
        boolean flag = false;
        boolean flag1 = false;
        boolean flag2 = false;
        boolean flag3 = false;
        boolean flag4 = false;
        boolean flag5 = false;
        int j = 0;
        boolean flag6 = false;
        int l;
        for(l = abyte0.length; abyte0[l - 1] == 61;)
            if(--l == 0)
                return new byte[0];

        abyte1 = new byte[l - i];
        for(int i1 = 0; i1 < i; i1++)
        {
            int k = i1 * 4;
            byte byte5 = abyte0[k + 2];
            byte byte6 = abyte0[k + 3];
            byte byte0 = base64Alphabet[abyte0[k]];
            byte byte1 = base64Alphabet[abyte0[k + 1]];
            if(byte5 != 61 && byte6 != 61)
            {
                byte byte2 = base64Alphabet[byte5];
                byte byte4 = base64Alphabet[byte6];
                abyte1[j] = (byte)(byte0 << 2 | byte1 >> 4);
                abyte1[j + 1] = (byte)((byte1 & 0xf) << 4 | byte2 >> 2 & 0xf);
                abyte1[j + 2] = (byte)(byte2 << 6 | byte4);
            } else
            if(byte5 == 61)
                abyte1[j] = (byte)(byte0 << 2 | byte1 >> 4);
            else
            if(byte6 == 61)
            {
                byte byte3 = base64Alphabet[byte5];
                abyte1[j] = (byte)(byte0 << 2 | byte1 >> 4);
                abyte1[j + 1] = (byte)((byte1 & 0xf) << 4 | byte3 >> 2 & 0xf);
            }
            j += 3;
        }

        return abyte1;
    }

    public static String encodeString(String s)
    {
        byte abyte0[] = encode(s.getBytes());
        String s1 = new String(abyte0);
        return s1;
    }

    public static String decodeString(String s)
    {
        byte abyte0[] = decode(s.getBytes());
        String s1 = new String(abyte0);
        return s1;
    }

    public static void main(String args[])
    {
        BASE64Decoder base64decoder = new BASE64Decoder();
        BASE64Encoder base64encoder = new BASE64Encoder();
        try
        {
            byte abyte0[] = base64decoder.decodeBuffer("admin");
            String s = new String(abyte0);
            String s2 = base64encoder.encodeBuffer(abyte0);
            String s3 = new String(s);
        }
        catch(IOException ioexception)
        {
            ioexception.printStackTrace();
        }
        byte abyte1[] = encode("admin".getBytes());
        String s1 = new String(abyte1);
        byte abyte2[] = decode(s1.getBytes());
        String s4 = new String(abyte2);
    }

    static
    {
        base64Alphabet = new byte[255];
        lookUpBase64Alphabet = new byte[64];
        for(int i = 0; i < 255; i++)
            base64Alphabet[i] = -1;

        for(int j = 90; j >= 65; j--)
            base64Alphabet[j] = (byte)(j - 65);

        for(int k = 122; k >= 97; k--)
            base64Alphabet[k] = (byte)((k - 97) + 26);

        for(int l = 57; l >= 48; l--)
            base64Alphabet[l] = (byte)((l - 48) + 52);

        base64Alphabet[43] = 62;
        base64Alphabet[47] = 63;
        for(int i1 = 0; i1 <= 25; i1++)
            lookUpBase64Alphabet[i1] = (byte)(65 + i1);

        int j1 = 26;
        for(int k1 = 0; j1 <= 51; k1++)
        {
            lookUpBase64Alphabet[j1] = (byte)(97 + k1);
            j1++;
        }

        j1 = 52;
        for(int l1 = 0; j1 <= 61; l1++)
        {
            lookUpBase64Alphabet[j1] = (byte)(48 + l1);
            j1++;
        }

        lookUpBase64Alphabet[62] = 43;
        lookUpBase64Alphabet[63] = 47;
    }
}
